package service.Impl;

import dao.BookDao;
import dao.UserDao;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import service.BookService;

public class BookServiceImpl implements BookService, InitializingBean, DisposableBean {
    //删除使用new创建bookDao； 因为我们现在用IOC了
    //private BookDao bookDao = new BookDaoImpl();
    private BookDao bookDao;
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public BookDao getBookDao() {
        return bookDao;
    }

    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }

    @Override
    public void save() {
        System.out.println("Book Service准备调用dao层的save");
        bookDao.save();
        userDao.save();
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("service destroy");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("service init");
    }
}
